package cd.cdyb.sms.config;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.List;

/**
 * <p>类简述：系统中已经登录后的用户对象</p>
 * <p>
 * <p>描述：用户登陆后，该对象会被放置到缓存中，spring security会使用该对象的权限来做权限控制处理</p>
 * <p>
 * <p>补充：</p>
 *
 * @author Junpeng.Su
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class LoginUserSecurityDto extends BaseSecurityDto implements UserDetails {

    private static final long serialVersionUID = -855000837240325299L;//TODO 解决和非DUBBO兼容问题，如果非DUBBO停止使用，需要将该类移动到

    /**
     * 密码
     */
    private String password;

    /**
     * 用户名
     */
    private String username;

    /**
     * 手机号
     */
    private String phone;

    private List<AuthorityDto> authorities;
    private List<Long> authoritieIds;
    private boolean accountNonExpired;
    private boolean accountNonLocked;
    private boolean credentialsNonExpired;
    private boolean enabled;

    /**
     * 令牌
     */
    private String accessToken;

    /**
     * 公司ID
     */
    private Integer companyId;

    @Override
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public List<AuthorityDto> getAuthorities() {
        return authorities;
    }

    public void setAuthorities(List<AuthorityDto> authorities) {
        this.authorities = authorities;
    }

    public List<Long> getAuthoritieIds() {
        return authoritieIds;
    }

    public void setAuthoritieIds(List<Long> authoritieIds) {
        this.authoritieIds = authoritieIds;
    }

    @Override
    public boolean isAccountNonExpired() {
        return accountNonExpired;
    }

    public void setAccountNonExpired(boolean accountNonExpired) {
        this.accountNonExpired = accountNonExpired;
    }

    @Override
    public boolean isAccountNonLocked() {
        return accountNonLocked;
    }

    public void setAccountNonLocked(boolean accountNonLocked) {
        this.accountNonLocked = accountNonLocked;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return credentialsNonExpired;
    }

    public void setCredentialsNonExpired(boolean credentialsNonExpired) {
        this.credentialsNonExpired = credentialsNonExpired;
    }

    @Override
    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }


}
